﻿using System;
using System.Collections.Generic;

namespace MakeBorderless
{
    [Serializable]
    public enum GroupType
    {
        None,
        UseWindowName,
        UseProcessName
    }

    [Serializable]
    public class Settings
    {
        public Settings()
        {
            SavedNames = new List<string>();
        }

        public Settings(GroupType group, bool minimized, List<string> names)
        {
            GroupBy = group;
            RunMinimized = minimized;
            SavedNames = names;
        }

        public GroupType GroupBy { get; set; }

        public bool GroupEnabled
        {
            get
            {
                return (GroupBy != GroupType.None);
            }
        }

        public bool RunMinimized { get; set; }

        public List<string> SavedNames { get; set; }

        public object Copy()
        {
            Settings settings = new Settings();
            foreach (string s in SavedNames)
            {
                settings.SavedNames.Add(s);
            }
            settings.GroupBy = GroupBy;
            settings.RunMinimized = RunMinimized;
            return settings;
        }

        public override bool Equals(object obj)
        {
            return (this == (Settings)obj);
        }

        public override int GetHashCode()
        {
            return (SavedNames.GetHashCode() ^ GroupBy.GetHashCode() ^ RunMinimized.GetHashCode());
        }

        public static bool operator ==(Settings a, Settings b)
        {
            if (System.Object.ReferenceEquals(a, b))
            {
                return true;
            }
            if (((object)a == null) || ((object)b == null))
            {
                return false;
            }
            if (a.GroupBy != b.GroupBy ||
                a.RunMinimized != b.RunMinimized)
            {
                return false;
            }
            if (a.SavedNames.Count != b.SavedNames.Count)
            {
                return false;
            }
            for (int i = 0; i < a.SavedNames.Count; i++)
            {
                if (a.SavedNames[i] != b.SavedNames[i])
                {
                    return false;
                }
            }
            return true;
        }

        public static bool operator !=(Settings a, Settings b)
        {
            return !(a == b);
        }
    }
}